part of '../controller.dart';

class _NotificationDtoFactory {
  const _NotificationDtoFactory._internal();

  static const _instance = _NotificationDtoFactory._internal();

  factory _NotificationDtoFactory() {
    return _instance;
  }

  _NotificationDataDto fromJson(Map<String, dynamic> json) {
    final oneTimePurchaseItemNotificationDataJson =
        json['oneTimeProductNotification'] as Map<String, dynamic>?;

    final subscriptionNotificationDataJson =
        json['subscriptionNotification'] as Map<String, dynamic>?;

    final testNotificationDataJson = json['testNotification'] as Map<String, dynamic>?;

    if (oneTimePurchaseItemNotificationDataJson != null) {
      return _OneTimePurchaseItemNotificationDataDto.fromJson(
          oneTimePurchaseItemNotificationDataJson);
    }

    if (subscriptionNotificationDataJson != null) {
      return _SubscriptionNotificationDataDto.fromJson(subscriptionNotificationDataJson);
    }

    if (testNotificationDataJson != null) {
      return const _TestNotificationDataDto();
    }

    throw UnimplementedError();
  }
}
